<template>
  <div class="like-list">
    <div v-for="(item,index) in list" :key="index" class="like-item" @click="onItemClick(item)">
      <van-image lazy-load :src="item.picUrl" width="8rem" height="8rem"/>
      <div class="like-item-info">
        <span class="like-item-title">{{ item.name }}</span>
        <div class="like-item-price-wrap">
          <span>¥<span class="like-item-price">{{ item.retailPrice }}</span></span>
          <span class="sold-count">已售1件</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ItemList',
  props: {
    list: Array
  },
  methods: {
    onItemClick(item) {
      this.$emit('onItemClick', item)
    }
  }
}
</script>

<style scoped>
.like-list {
  background: #f3f3f3;
  width: 100%;
}
.like-item img{
  width: 100%;
  text-align: center;
}
.like-item {
  float: left;
  margin: 10px 5px 0 5px;
  background-color: white;
  padding: 15px;
  box-sizing: border-box;
  border-radius: 5px;
  box-shadow: 4px 4px 4px rgba(0, 0, 0, .05);
  width: 47%;
}

.like-item-info {
  display: flex;
  flex-direction: column;
}

.like-item-title {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  margin-top: 5px;
}

.like-item-price {
  font-size: 16px;
  font-weight: bold;
}

.like-item-price-wrap {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 12px;
  color: #E65D6E;
}

.sold-count {
  color: #c5c5c5;
}
</style>
